Sometimes you get results that you don't expect. Most of the time the cause of the error is related to the user not understanding exactly what the syntax is/should be. But there is the occasional insiduous issue related to using the wrong version, library files being mixed up or simply that you think a particular state (such as username) is 'xyz' when in fact it is 'abc.' Here are some checks to make sure that you cover your bases.
import sys
print("Python version: ", sys.version)
import os
print("Python is installed in : ", os.path.dirname(sys.executable))
import pandas
print("Pandas version: ", pandas.__version__)
import inspect
print("Pandas is installed in : ", inspect.getfile(pandas))
You should get the pretty print (pprint) module for this. Note that you can get:
import pprint
pprint.pprint(dict(os.environ), width=1)
In case that you don't have code completion enabled
data = {'CBOE/VIX': 'VIX Close', 'FRED/TEDRATE': ''}
pprint.pprint(dir(data), width=1)
print(type(data))
print("")
if data.__class__ == 'str'.__class__:
print("varialbe is a '{0}' and has value = {1}".format(x.__class__, x))
elif data.__class__ == [1, 2, "list"].__class__:
for item in data:
print("Item has value = {}".format(item))
else:
for key, values in data.items():
print("key has type = '{0}' and value = '{1}'".format(type(key), key))
print("values has type = '{0}' and value = '{1}'".format(type(values), values))
print("")
import os.path
PATH='/Users/gonzalobriceno/Files/music.txt'
if os.path.isfile(PATH) and os.access(PATH, os.R_OK):
print("File exists and is readable")
else:
print("Either file is missing or is not readable")
Remember that a return vaue of 0 means the call was successful
command = 'cp /Users/gonzalobriceno/Files/music.txt /Users/gonzalobriceno/Files/music2.txt'
retvalue = os.system(command)
print('Command {0} returned {1}.'.format(command,retvalue))